using System;
using System.Reflection;

public sealed class Program {
   public static void Main() {
      // Loop through all assemblies loaded in this AppDomain
      Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
      foreach (Assembly a in assemblies) {
         Show(0, "Assembly: {0}", a);

         // Find Types in the assembly
         foreach (Type t in a.GetExportedTypes()) {
            Show(1, "Type: {0}", t);

            // Indicate the kinds of members we want to discover
            const BindingFlags bf = BindingFlags.DeclaredOnly |
               BindingFlags.NonPublic | BindingFlags.Public |
               BindingFlags.Instance | BindingFlags.Static;

            // Discover the type's members
            foreach (MemberInfo mi in t.GetMembers(bf)) {
               String typeName = String.Empty;
               if (mi is Type)            typeName = "(Nested) Type";
               if (mi is FieldInfo)       typeName = "FieldInfo";
               if (mi is MethodInfo)      typeName = "MethodInfo";
               if (mi is ConstructorInfo) typeName = "ConstructoInfo";
               if (mi is PropertyInfo)    typeName = "PropertyInfo";
               if (mi is EventInfo)       typeName = "EventInfo";

               Show(2, "{0}: {1}", typeName, mi);
            }
         }
      }
   }
   
   private static void Show(Int32 indent, String format, params Object[] args) {

      Console.WriteLine(new String(' ', 3 * indent) + format, args);
   }
}
